<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>Untitled Document</title>
	</head>
	<body>
		<script src="iban.js"></script>
		<script type="text/javascript">
			var iban = "GR16 0110 1250 0000 0001 2300 695";		//The IBAN number to be validated
			/*
			 * Get the ISO 3166 country code from the IBAN number by calling getCountryCode. If there is some problem
			 * with the country code or the control digits(characters 3 and 4) in the IBAN, it will be reported in the 
			 * object returned by getCountryCode. The object returned has 2 properties
			 *  - If the country code and the control digits are proper, the object returned has "isValid"
			 *    property set to true and a "value" property that denotes the value of the country code
			 *  - If either the country code or the control digits are improper, the object returned has "isValid"
			 *    property set to false and a "errorString" property containing the error string
			 */
			var countryCode = ibanValidator.getCountryCode(iban);
			if(countryCode.isValid)
				alert("Country code : " + countryCode.value);
			/*
			 * All IBAN starts with 2 Uppercase alphabets representing the country code followed by 2 digits 
			 * representing the control digits. The rest of the characters constitute the BBAN part of the IBAN which 
			 * varies depending on the country. BBAN part of an IBAN is represented in terms of upper case alpha 
			 * characters (A-Z) denoted by "a", numeric characters (0-9) denoted by "n" and mixed case alphanumeric 
			 * characters (a-z, A-Z, 0-9) denoted by "c". For example, the Bulgarian BBAN (4a,6n,8c) consists of 4 alpha
			 * characters, followed by 6 numeric characters, then by 8 mixed-case alpha-numeric characters. 
			 * Refer "http://en.wikipedia.org/wiki/International_Bank_Account_Number" for details
			 * Now using the country code, the IBAN character count and the BBAN format has to be retrieved from some
			 * application object, DB etc.
			 */
			var country = "Greece", charCount = 27, bban = "7n,16c";
			/*
			 * Invoke the isValidIBAN function with the iban number, country, character count of IBAN and BBAN format.
			 * The object returned has atmost 2 properties
			 *  - If the IBAN is valid, the object returned has "isValid" property set to true
			 *  - If the IBAN is invalid, the object returned has "isValid" property set to false and a "errorString"
			 *    property containing the error string
			 */
			var result = ibanValidator.isValidIBAN(iban,country,charCount,bban);
			if(result.isValid)
				alert("The number provided is a valid IBAN");
			else
				alert(result.errorString);
		</script>
	</body>
</html>
